package cn.yuan.xiaoyu.caipumodule.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import cn.yuan.xiaoyu.R;
import cn.yuan.xiaoyu.caipumodule.bean.CaiPuTagListBean;
import cn.yuan.xiaoyu.commonmodule.utils.ListUtils;

/**
 * Created by yukuoyuan on 2017/2/28.
 * 这是一个菜谱大全的标签列表的适配器
 */

public class CaiPuTagListAdapter extends RecyclerView.Adapter<CaiPuTagListAdapter.MyHolder> {
    List<CaiPuTagListBean.ResultBean.ListBean> listBeen;

    public CaiPuTagListAdapter(List<CaiPuTagListBean.ResultBean.ListBean> listBeen) {
        this.listBeen = listBeen;
    }

    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(parent.getContext(), R.layout.item_caipu_tag_list, null);
        return new MyHolder(view);
    }

    @Override
    public void onBindViewHolder(MyHolder holder, int position) {
        holder.tv_item_caipu_tag_list.setText(listBeen.get(position).name);
    }

    @Override
    public int getItemCount() {
        if (ListUtils.isEmpty(listBeen)) {
            return 0;
        }
        return listBeen.size();
    }

    class MyHolder extends RecyclerView.ViewHolder {

        private final TextView tv_item_caipu_tag_list;

        public MyHolder(View itemView) {
            super(itemView);
            tv_item_caipu_tag_list = (TextView) itemView.findViewById(R.id.tv_item_caipu_tag_list);
        }
    }
}
